package com.example.demo.vo

import com.example.demo.dao.TMessageDao
import com.example.demo.dao.TPatientDao
import com.example.demo.dbmodels.TMessage
import me.liuwj.ktorm.dsl.QueryRowSet

class MessageVo {


    /**
     *  id
     **/
    var id: Int? = null

    /**
     *  消息标题
     **/
    var title: String? = null

    /**
     *  消息内容
     **/
    var context: String? = null

    /**
     *  图片地址
     **/
    var imgurl: String? = null

    /**
     *  文件地址
     **/
    var fileurl: String? = null

    /**
     *  消息类型
     **/
    var type: String? = null
    /**
     *  消息类型
     **/
    var patient_id: String? = null
    /**
     *  消息类型
     **/
    var time: String? = null
    /**
     *  消息类型
     **/
    var dept_code: String? = null

    fun getMessageVo(table: TMessage): MessageVo? {
        table.apply {
            val data = MessageVo()
            data.id = id
            data.context = context
            data.fileurl = fileurl
            data.imgurl = imgurl
            data.title = title
            data.type = type
            data.patient_id = patient_id
            data.time = time
            data.dept_code = dept_code
            return data
        }
    }

    fun getMessageVoList(table: List<TMessage>?): List<MessageVo>? {
        table.let {
            val datas = mutableListOf<MessageVo>()
            it?.forEach {
                val data = MessageVo()
                data.id = it.id
                data.context = it.context
                data.fileurl = it.fileurl
                data.imgurl = it.imgurl
                data.title = it.title
                data.type = it.type
                data.patient_id = it.patient_id
                data.time = it.time
                data.dept_code = it.dept_code
                datas.add(data)
            }
            return datas
        }
    }


    fun getMessageVo(queue: QueryRowSet): MessageVo {
        queue.let {
            val data = MessageVo()
            data.id = it[TMessageDao.id]
            data.context = it[TMessageDao.context]
            data.fileurl =it[TMessageDao.fileurl]
            data.imgurl = it[TMessageDao.imgurl]
            data.title =  it[TMessageDao.title]
            data.type = it[TMessageDao.type]
            data.patient_id = it[TMessageDao.patient_id]
            data.time = it[TMessageDao.time]
            return data
        }
    }


}